import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  // 配置路由规则
  {
    path:'/login',
    name:'/login',
    component:()=>import('@/views/login/index.vue')
  },
  // 搜索路由规则
  {
    path:'/search',
    name:'/search',
    component:()=>import('@/views/search/index.vue')
  },
  // 文章详情页路由规则 动态路由
  {
    path:'/article/:articleId',
    name:'/article',
    component:()=>import('@/views/article/index.vue'),
    props:true //开启props传参 解耦
  },
  {
    path:'/',
    // name:'/layout',
    component:()=>import('@/views/layout/index.vue'),
    // 配置底部Tab的子路由
    children:[
      {
        path:'',
        name:'home',
        component:()=>import('@/views/home/index.vue')
      },
      {
        path:'/qa',
        name:'qa',
        component:()=>import('@/views/qa/index.vue')
      },
      {
        path:'/video',
        name:'video',
        component:()=>import('@/views/video/index.vue')
      },
      {
        path:'/my',
        name:'my',
        component:()=>import('@/views/my/index.vue')
      },
      {
        name: 'user-profile',
        path: '/user/profile',
        component: () => import('@/views/user-profile')
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
